function [] = plotEntropyFree( dirName, fileNum, M , N )

loopNum = 1; % control the circle number
fileArray = dir(dirName);

entropyMax = zeros(1, loopNum);
ncArray = zeros(1, loopNum);

entropyArray = zeros(1,N-M+1);
numNeighboorArray = zeros(1,N-M+1);

for second = 1 : loopNum % for only one frame, t1 = t2
    
    %-------------------------Preparation--------------------------%
    
    nameCat = [dirName,'\',fileArray(fileNum+2+second).name];
    [position,velocity,num]=readText( nameCat );
    
    distance = zeros( num,num );
    expCorr = zeros(num,num);
%     count = zeros(1,maxN);
%     C = zeros(1,maxN);
    
    for i= 1 : num
        for j = 1: num
            distance(i,j) = norm(position(i,:)-position(j,:));
            expCorr(i,j) = sum(velocity(i,:).*velocity(j,:));
%             temp = floor((distance(i,j)/deltaR))+1;
%             if temp < maxN
%             C(temp) = C(temp) + expCorr(i,j);
%             count(floor((distance(i,j)/deltaR))+1) = count(floor((distance(i,j)/deltaR))+1)+1;
%             end
        end
    end % acquire distance and correlation between i and j

%     meanC = C ./ count; %
    
    %--------------------Compute Entropy------------------------%

    for i = M : N
        numNeighboor = i;
        [logic, intCorrelation,~] = computeIntCorrelation( num ,numNeighboor ,distance ,expCorr,true(1,num) );
        matrixNij = 0.5 * (logic + logic'); % when i = j ,logic(i,j) = False
        diagnoalA_ij = sum(matrixNij);
        A_ = diag(diagnoalA_ij) - matrixNij;
        lamda = eig(A_); % eigenvalue need to be sorted, matlab do it as default
        J = 2/(numNeighboor*(1-intCorrelation));
        % disp(J);

        lamda(1) = 1/J; % to delete the first eigenvalue: 0
        log_a = log(J*lamda);
        sigmaLog_a = sum(log_a);
        entropy = (0.5*sigmaLog_a - num)/num;
      
        entropyArray(i-M+1) = entropy;  
        numNeighboorArray(i-M+1) = numNeighboor;
    end
    entropyMax(second) = max(entropyArray);
    
    logicNc = entropyMax(second) == entropyArray ; 
    nc = numNeighboorArray(logicNc); % can be replaced by "find" function ...
   
    ncArray(second) = max(nc);
    % to find the nc when entropy reachs maximum


end

%-----------------------------PLOT-----------------------------------%
 
figure
plot( M : N ,entropyArray)
title(nameCat) % plot the pic of last frame for check

figure
plot(1:loopNum, ncArray,'r.')

ncAverage = sum(ncArray) / length(ncArray)
ncDeviation = (sum((ncArray - ncAverage).^2) / length(ncArray))^0.5

